home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!news1!ts02-and-20
- From: dlmiller@iquest.net (Doug & Rose Miller)
- Subject: Re: Converting Strings to Upper Case
- X-Nntp-Posting-Host: ts00-and-02.iquest.net
- Message-ID: <DoFA24.AL7@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Network Services
- X-Newsreader: News Xpress Version 1.0 Beta #2.1
- References: <4ifra6$52i@scipio.cyberstore.ca>
- Date: Sun, 17 Mar 1996 17:27:08 GMT
-
- ejw@news.cyberstore.ca () wrote:
- +Hi,
- +
- +I need to write a function to convert a string containg upper or lower case
- +characters to the opposite case. Something like:
- +
- + void libConvertUpperCase(char *str); and
- + void libConvertLowerCase(char *str);
- +
- +and the string would be modified. I just can't seem to wrap my head around
- +the best way that I know is better than writing a for loop to check each
- +element in the array?
- +
- +I apologize if this in the FAQ; I am still going thorugh it. Any help
- +would be greatly appreciated.
- +
- +Eric Woodward.
- +ejw@cyberstore.ca.
- +
-
-
- #include <stdio.h>
-
- void main (void) {
- char test[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
- char *p;
-
- printf ("%s\n", &test);
- for (p = test; *p; *p++)
- if (isalpha(*p)) *p ^= 0x20; /* for ascii machines e.g. PC; use 0x40 for ebcdic machines e.g. IBM mainframe */
- printf ("%s\n", &test);
- }
-
-